<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../plugins/layui/css/myPage.css">
</head>
<body  >
<div class="layui-container">

    <form class="layui-row layui-form">

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>新增部门</legend>
            </fieldset>

                <div class="layui-form-item">
                    <label class="layui-form-label">部门名称</label>
                    <div class="layui-input-inline" style="width: 150px;">
                        <input   type="text" name="name"  required lay-verify="required" placeholder="请输入"  class="layui-input"  >
                        <input   type="hidden" name="sjbm"  id="sjbm" value="1" class="layui-input"  >
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label">负责人</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input type="text" name="fzr" autocomplete="off" lay-verify="required" required class="layui-input">
                        </div>
                    </div>

                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">联系方式</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input type="text" name="lxfs" autocomplete="off" lay-verify="required" required class="layui-input">
                        </div>
                    </div>
                    <label class="layui-form-label">上级部门</label>

                    <div class="layui-input-inline" style="width: 150px;">
                        <div class="layui-input-inline" style="width: 150px;">
                            <select name="fjdid" lay-verify="required" required lay-search="" id="fjdid" style="width: 150px;" >
                                <option value="">搜索选择</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">部门简介</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" class="layui-textarea" name="bmjj" style="width: 420px"></textarea>
                        <input type="hidden" name="sfcz" value="1" />
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">

                        <div  type="reset" class="layui-btn layui-btn-normal"  lay-submit lay-filter="new" >提交</div>
                        <div  class="layui-btn layui-btn-normal" id="close">关闭</div>
                    </div>
                </div>



    </form>
</div>
<script src="../plugins/layui/layui.js"></script>
<script src="../js/config.js"></script>
<script src="../js/tools.js"></script>
<script>
    layui.use(['table','form','layer'],function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.$;
        var layer = layui.layer;


        $("#close").on('click',function(){
            console.log("close");
            //当你在iframe页面关闭自身时
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });
        $.ajax({
            url: contextPath+"/dept",
            type: "GET",
            contentType:"application/json;charset=utf-8",
            dataType:"json",
            success: function(res) {

                for(var i in res.list){

                    var option = "<option value='"+ res.list[i].bumenid+ "'>"+res.list[i].name+"</option>";

                    $("#fjdid").append(option);
                };
                form.render('select');
            }

        });


        //监听工具条

        form.on('submit(new)', function(data){


            $("input").css("border","");
            $.ajax({
                url: contextPath+"/dept",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data: JSON.stringify(data.field) ,
                dataType:"json",
                success: function(res) {
                    newSuccess($,layer,res);
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });

</script>
</body>
</html>